const PICKER_OPTIONS = {
  disabledDate (time) {
    return time.getTime() < new Date().getTime() - 86400000;
  }
};
// 供应商表头
export const getSupplierColumns = (parent) => {
  return [
    {
      prop: 'supplierName',
      label: '供应商名称',
      width: 120
    },
    {
      prop: 'supplierCode',
      label: '供应商代码',
      width: 90
    },
    {
      prop: 'supplierStatusName',
      label: '供应商状态',
      width: 90
    },
    {
      prop: 'supplierLevel',
      label: '供应商等级',
      width: 90
    },
    {
      prop: 'quoteStatusName',
      label: '报价状态'
    },
    // 原字段onlineCollaboration 18913为是，18914为否
    {
      prop: 'onlineCollaborationName',
      label: '询价单是否协同',
      width: 110
    },
    {
      prop: 'supplierLinkman',
      label: '供应商联系人',
      width: 100
    },
    {
      prop: 'supplierPhone',
      label: '供应商电话',
      width: 90
    },
    {
      prop: 'offerEndTime',
      label: '报价有效期'
    },
    {
      prop: 'fileGroupId',
      label: '供应商附件',
      width: 90,
      render: (h, { row }) => {
        if (row.fileGroupId) {
          return <el-link onClick={() => parent.handleViewFileList(row)} type="primary">查看附件</el-link>
        }
      }
    },
  ]
}
// 报价详情 商品列表表头
export const GOODS_TABLE_COLUMNS = [
  {
    prop: 'fourCategoryCode',
    label: '四级类代码',
  },
  {
    prop: 'fourCategoryName',
    label: '四级类名称',
  },
  {
    prop: 'productBrand',
    label: '品牌',
  },
  {
    prop: 'skuCode',
    label: '商品代码',
  },
  {
    prop: 'skuName',
    label: '商品名称',
    width: 150
  },
  {
    prop: 'priceAccurateStr',
    label: '价格是否准确',
  },
  {
    prop: 'productSpec',
    label: '规格型号',
  },
  {
    prop: 'unit',
    label: '计量单位',
  },
  {
    prop: 'amount',
    label: '数量',
  },
]

// 报价信息 表头
export const QUOTE_INFO_TABLE_COLUMNS = [
  {
    prop: 'skuStatusStr',
    label: '商品状态',
    fixed: 'left',
  },
  {
    prop: 'factoryCode',
    label: '厂家商品代码',
    fixed: 'left',
    width: '100'
  },
  {
    prop: 'factoryName',
    label: '厂家商品名称',
    fixed: 'left',
    width: '100'
  },
  {
    prop: 'skuCode',
    label: '商品代码',
    fixed: 'left',
  },
  {
    prop: 'skuName',
    label: '商品名称',
    fixed: 'left',
  },
  {
    prop: 'skuBrand',
    label: '品牌',
  },
  {
    prop: 'skuSpecifications',
    label: '规格型号',
  },
  {
    prop: 'skuUnit',
    label: '主计量单位',
  },
  {
    prop: 'assistSkuUnit',
    label: '辅计量单位',
  },
  {
    prop: 'pieceQty',
    label: '件装数量',
  },
  {
    prop: 'addPriceTypeStr',
    label: '加价类型',
  },
  {
    prop: 'rebateRatio',
    label: '返利折合比例/金额',
    width: 120
  },
  {
    prop: 'skuNum',
    label: '主数量',
  },
  {
    prop: 'assistSkuNum',
    label: '辅数量',
    width: '100'
  },
  {
    prop: 'adjustedSkuNum',
    label: '调整后数量',
    width: '125',
    type: 'inputNumChange',
    required: true,
  },
  {
    prop: 'unitPrice',
    label: '主进价',
    width: '100'
  },
  {
    prop: 'priceExpireTime',
    label: '价格有效期',
    width: '200',
    type: 'dateTime',
    pickerOptions: PICKER_OPTIONS,
    required: true
  },
  {
    prop: 'supplierPrice',
    label: '供应商报价',
    width: '120'
  },
  {
    prop: 'assistUnitPrice',
    label: '辅进价',
    width: '125',
    required: true,
    type: 'inputNumChange',
    precision: 3
  },
  {
    prop: 'workableArrivalTime',
    label: '落实到货时间',
    width: '200',
    type: 'dateTime',
    required: true,
    clearable: false,
    pickerOptions: PICKER_OPTIONS
  },
  {
    prop: 'reqArrivalTime',
    label: '要求到货时间',
    width: '150'
  },
  {
    prop: 'sharePrice',
    label: '费用分摊金额',
  },
  {
    prop: 'scmRemark',
    label: '供应商备注',
    width: 100
  },
  {
    prop: 'costPrice',
    label: '成本价',
  },
  {
    prop: 'totalPrice',
    label: '金额小计',
  },
]
// 自进货定标查看表头
export const BID_VIEW_COLUMNS = [
  {
    label: '商品代码',
    prop: 'skuCode',
  },
  {
    label: '商品名称',
    prop: 'skuName',
  },
  {
    label: '规格型号',
    prop: 'productSpec',
    width: 70,
  },
  {
    label: '单位',
    prop: 'unit',
    width: 50,
  },
  {
    label: '数量',
    prop: 'amount',
    width: 50,
  },
  {
    label: '最低价供应商',
    prop: 'lowCostPriceSupplyName',
  },
  {
    label: '最低供应商成本价',
    prop: 'lowCostPrice',
  },
  {
    label: '下限',
    prop: 'lowerQty',
  },
  {
    label: '上限',
    prop: 'upperQty',
  },
  {
    label: '采购在途',
    prop: 'purchaseTransitQty',
  },
  {
    label: '实物可售',
    prop: 'physicalSellQty',
  },
  {
    label: '调货短缺',
    prop: 'shortageGoods',
  },
  {
    label: '件装数量',
    prop: 'pieceQty',
  },
  {
    label: '3个月销量',
    prop: 'threeOut',
  },
  {
    label: '同期出库',
    prop: 'thisPeriodOut',
  },
  {
    label: '全年出库',
    prop: 'allYearOut',
  },
  {
    label: '缺货公司',
    prop: 'shortSupplyCompanyName',
  },
  {
    label: '是否超上限1.2倍要货',
    prop: 'isExceedNum',
    width: 140,
  },
  {
    label: '超上限1.2倍原因',
    prop: 'exceedNumReason',
    width: 120,
  },
  {
    label: '是否超3个月销量',
    prop: 'isExceedThreeOut',
    width: 140,
  },
  {
    label: '超3个月销量原因',
    prop: 'exceedThreeOutReason',
    width: 120,
  },
]

// 自进货定标编辑表头
export const BID_EDIT_COLUMNS = [
  {
    label: '商品代码',
    prop: 'skuCode',
  },
  {
    label: '商品名称',
    prop: 'skuName',
  },
  {
    label: '规格型号',
    prop: 'productSpec',
    width: 70,
  },
  {
    label: '单位',
    prop: 'unit',
    width: 50,
  },
  {
    label: '数量',
    prop: 'amount',
    width: 50,
  },
  {
    label: '最低价供应商',
    prop: 'lowCostPriceSupplyName',
  },
  {
    label: '最低供应商成本价',
    prop: 'lowCostPrice',
  },
  {
    label: '下限',
    prop: 'lowerQty',
  },
  {
    label: '上限',
    prop: 'upperQty',
  },
  {
    label: '采购在途',
    prop: 'purchaseTransitQty',
  },
  {
    label: '实物可售',
    prop: 'physicalSellQty',
  },
  {
    label: '调货短缺',
    prop: 'shortageGoods',
  },
  {
    label: '件装数量',
    prop: 'pieceQty',
  },
  {
    label: '3个月销量',
    prop: 'threeOut',
  },
  {
    label: '同期出库',
    prop: 'thisPeriodOut',
  },
  {
    label: '全年出库',
    prop: 'allYearOut',
  },
  {
    label: '缺货公司',
    prop: 'shortSupplyCompanyName',
  },
  {
    label: '异常类型',
    prop: 'priceExpType',
    render: (h, { row }) => {
      if (row.priceExpTypeList && row.priceExpTypeList.length) {
        return <span style="color: red">{row.priceExpTypeList.map(item => item.priceExpType).join('，')}</span>
      }
    }
  },
  {
    label: '异常原因',
    prop: 'priceExpReason',
    render: (h, { row }) => {
      if (!row.priceExpTypeList) {
        return ''
      }
      return <el-popover
        placement="right"
        width="600"
        trigger="hover">
        <el-table border data={row.priceExpTypeList}>
          <el-table-column property="priceExpType" label="异常类型"></el-table-column>
          <el-table-column property="concreteExpCause" label="异常原因"></el-table-column>
          <el-table-column property="content" label="原因说明"></el-table-column>
        </el-table>
        <a style="color: red" slot="reference">查看</a>
      </el-popover>
    }
  },
]
// 自进货定标编辑表头 动态部分
export const BID_EDIT_DYNAMIC_COLUMNS = [
  {
    label: '归属中心',
    prop: 'belongDepartmentName',
  },
  {
    label: '成本价',
    prop: `costPrice`,
  },
  {
    label: '进价',
    prop: `unitPrice`,
    width: 60
  },
  {
    label: '中标数量',
    prop: `skuNum`,
    type: 'inputNumChange',
    width: 125,
    class: 'active',
  },
  {
    label: '中标金额',
    prop: `skuPrice`,
  },
  {
    label: '报价金额',
    prop: `totalPrice`,
  },
  {
    label: '落实到货时间',
    prop: `workableArrivalTime`,
  },
  {
    label: '备注',
    prop: `remark`,
    type: 'input',
    width: 100
  },
  {
    label: '供货进价',
    prop: `productCenterPrice`
  },
  {
    label: '供货成本价',
    prop: `productCenterCostPrice`
  }
]
